package org.madmac.login;

import org.madmac.modulo.ModuloQuery;
import org.wakeful.conn.Connection;
import org.wakeful.query.Query;

/**
 *
 * @author atila camurca
 */
public final class LoginQuery {

   public static final String TABLE = Connection.getSchema().concat(Query.DOT).concat("usuario");
   public static final String ALIAS = TABLE.concat(" u");

   private LoginQuery() {}

   public static String validarUsuario() {
      StringBuilder builder = new StringBuilder();
      builder.append(Query.SELECT);
      builder.append("u.id_usuario, u.nickname, mod.descricao AS modulo");
      builder.append(Query.FROM);
      builder.append(LoginQuery.ALIAS);
      builder.append(Query.INNER_JOIN);
      builder.append(ModuloQuery.ALIAS);
      builder.append(Query.ON);
      builder.append("u.id_modulo = mod.id_modulo ");
      builder.append("WHERE u.login = ? AND u.senha = MD5(?)");
      return builder.toString();
   }
}
